package com.xtaller.easy.admin.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.xtaller.easy.admin.model.SysDict;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* Created by Taller on 2018/04/13
*/
@Mapper 
public interface SysDictMapper extends BaseMapper<SysDict> {
    @Select("Select * from sys_dict where isDel=0 and (moduleId=#{id} or parentId=#{id})")
    List<SysDict> getByModuleIdOrParentId(@Param("id") String id);

    @Select("SELECT a.`code` dict,a.`name`,b.`name` txt,b.`code` val FROM sys_dict a " +
            "LEFT JOIN sys_dict b on a.id=b.parentId " +
            "where a.`code` in (${code}) and b.isDel=0 and a.isDel=0 order by a.sort,b.sort ")
    List<JSONObject> getDictInByCode(@Param("code") String code);
}